<?php
include_once '/var/www/html/new/com.inc.php';
include_once '/var/www/html/new/d/class/ProductInfo.php';
include_once '/var/www/html/new/d/class/Member.php';
include_once '/var/www/html/new/d/class/DisOrder.php';
if(!isset($_SESSION['sid']))  exit('{"status":"fail","msg":"请先登录后再操作","code":0}');


if(!isset($_REQUEST['ordertel']) || $_REQUEST['ordertel']=='') exit("请输入取票人电话");
if(!isset($_REQUEST['ordername']) || $_REQUEST['ordername']=='') exit("请输入取票人姓名");

if(p_match($begintime = $_REQUEST['begintime']))  exit("游玩时间含有非法字符");
if(p_match($ordertel  = trim($_REQUEST['ordertel'])))  exit("取票人电话含有非法字符");
if(p_match($ordername = trim($_REQUEST['ordername'])))  exit("取票人含有非法字符");


if(($pid = $_REQUEST['pid'] + 0)==0 || ($aid = $_REQUEST['aid'] + 0)==0) exit('参数错误');


$option = array();
$option["pid"]       = $pid;
$option["tnum"]      = $_REQUEST['pids'][$pid]+0;
$option["ordertel"]  = $ordertel;
$option["ordername"] = $ordername;
$option["begintime"] = $begintime;
$option["leavetime"] = $_REQUEST['leavetime'];



$option["c_pids"]   = $_REQUEST['pids'];
$option['idcards']  = array();
$option['paymode']  = $_REQUEST['paymode']+0;
$option['memo'] = mysql_real_escape_string($_REQUEST['memo']);
if(isset($_REQUEST['sfz'])) $option['sfz'] = $_REQUEST['sfz'];
$option['tourists'] = $tourists;
unset($option['c_pids'][$option["pid"]]);


$ac = $GLOBALS['_ac'];
$pw = $GLOBALS['_pw'];
$inside   = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$m        = new Member($inside, $_SESSION['sid']);
$pro      = new ProductInfo($inside, $pid, $aid);
$disOrder = new DisOrder($inside, $pro, $m);


try{
	
	$r = $disOrder->order($option, $aid);
	write_logs(json_encode($r));
	$url="orderSuc.html?ordernum=".$r['orderNum'] . '&ot=' . md5($r['orderType']) ;
	if($_SESSION['dtype']==6){
		$daction="预订订单:{$r['orderNum']}";
		$str="insert pft_d_operation_rec set fid=".$_SESSION['memberID'].",sid=".$_SESSION['sid'].",rectime=now(),daction='$daction'";
		$GLOBALS['le']->query($str);
	}
	exit('{"status":"success","msg":"'.$url.'"}');
}catch(Exception $e){
	exit('{"status":"fail","msg":"'.$e->getMessage().'"}');
}






function write_logs($txt,$file="/var/www/html/new/d/logs/orderInfo_logs.txt"){
	$fp = fopen($file,"a");
	flock($fp, LOCK_EX);
	fwrite($fp,date("Y-m-d H:i:s").":".$txt."\n");
	flock($fp, LOCK_UN);
	fclose($fp);
}













































































